package com.example.myapplication.login;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import com.example.myapplication.PlayService;
import com.example.myapplication.R;
import com.example.myapplication.acticity.BaseActivity;

/**
 * 闪屏页
 */
public class SplashActivity extends BaseActivity {

    private static final int START_ACTIVITY = 0x1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        Intent intent = new Intent(this,PlayService.class);
        startService(intent);
        handler.sendEmptyMessageDelayed(START_ACTIVITY,2000);
    }

    @Override
    public void publish(int progress) {

    }

    @Override
    public void change(int position) {

    }

    /**
     * 展示三秒之后跳转登录页面
     */
    private Handler handler = new Handler(){
        @Override
        public void handleMessage(@NonNull Message msg) {
            super.handleMessage(msg);
            switch (msg.what){
                case START_ACTIVITY:
                    startActivity(new Intent(SplashActivity.this, MainActivity.class));
                    finish();
                    break;
            }

        }
    };
}
